<template>
    <div>
        <n-modal v-model:show="props.showModal" :mask-closable="true" @update:show="$emit('CheckShowModal', false)"
            preset="dialog" title="确认" content="确认删除?" positive-text="确认" negative-text="取消"
            @positive-click="onPositiveClick" @negative-click="onNegativeClick" />
    </div>
</template>

<script lang="ts" setup>
import { defineProps,reactive } from 'vue';
import { DelNav } from "@/api/menu"
import { useMessage } from 'naive-ui';
const emit = defineEmits(['CheckShowModal', 'reloadpage'])
const props = defineProps({
    showModal: {
        type: Boolean,
        default: false
    },
    userId: {
        type: Number,
        default: ''
    }
})
const params = reactive({
    nId:0,
})
const message = useMessage()
const onPositiveClick = () => {
params.nId=props.userId
    DelNav(params).then(res => {
        if (res.data == 1) {
           emit('CheckShowModal', false)
        emit('reloadpage')
        message.success('删除成功') 
        } else {
            emit('CheckShowModal', false)
        emit('reloadpage')
        message.success('删除失败') 
        }
        
    })


}

const onNegativeClick = () => {
    // console.log('false')
    emit('CheckShowModal', false)
}

</script>

<style scoped lang=scss>

</style>